<template>
  <Teleport to="#dialog">
    <div class="dialog">
      <div>
        <p>我是内容</p>
        <button @click="emit('close')">关闭</button>
      </div>
    </div>
  </Teleport>
</template>

<script setup>
  const emit = defineEmits(['close'])
</script>

<style lang="less" scoped>
.dialog {
  background-color: rgba(0, 0, 0, 0.7);
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  top: 0;
  > div {
    position: absolute;
    width: 200px;
    height: 150px;
    background-color: #fff;
    text-align: center;
    // margin-left: calc(50% - 100px);
    // margin-top: calc(50% - 75px);
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);

  }
}
</style>
